<UserControl x:Class="Locima.SlidingBlock.Controls.TileControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converters="clr-namespace:Locima.SlidingBlock.Converters"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="100" d:DesignWidth="100"
>

  <UserControl.Resources>
        <converters:PositionToStringConverter x:Key="PositionToStringConverter" />
        <converters:DoubleToThicknessConverter x:Key="DoubleToThicknessConverter" />
  </UserControl.Resources>
  <Canvas x:Name="TileRoot" Background="Transparent"
            Width="{Binding Width, Mode=OneWay}" 
            Height="{Binding Height, Mode=OneWay}" >
        <Rectangle x:Name="Tile" 
                   Width="{Binding Width, Mode=OneWay}"
                   Height="{Binding Height, Mode=OneWay}"
                   Canvas.Left="0"
                   Canvas.Top="0"
                   Fill="{Binding TileBrush}"
                   Visibility="{Binding TileImageVisibility}"
                   />
        <Rectangle x:Name="Player" 
                   Width="{Binding Width, Mode=OneWay}"
                   Height="{Binding Height, Mode=OneWay}"
                   Canvas.Left="0"
                   Canvas.Top="0"
                   Visibility="{Binding PlayerTileVisibility}"
                   Fill="{Binding PlayerBrush}"/>
        <TextBlock x:Name="TileText" Width="{Binding Width, Mode=OneWay}"
                   Canvas.Left="{Binding TileBorder}" Canvas.Top="{Binding TileBorder}"
                   TextAlignment="Center"
                   TextWrapping="Wrap"
                   Text="{Binding SolvedPosition, Converter={StaticResource PositionToStringConverter}}"
                   Visibility="{Binding TileDebugVisibility}"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"/>
        <Border x:Name="TileBorder" Width="{Binding Width}"
                Height="{Binding Height}"
                BorderThickness="{Binding TileBorder, Converter={StaticResource DoubleToThicknessConverter}}"
                BorderBrush="Black"
                Visibility="{Binding TileImageVisibility}"
                />
    </Canvas>
    
</UserControl>
